/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package components;

import java.util.Random;
import ruter.map.Geometry;

/**
 *
 * @author camilo
 */
public class GaussianRandomMove {

	private static final double ALPHA = 0.5;

	private Random random;
	public double x, y;
	private final double JUMPING_DISTANCE;

	public GaussianRandomMove(double jumpingDistance) {
		random = new Random(Double.doubleToLongBits(Math.random()));
		JUMPING_DISTANCE = jumpingDistance;
	}

	public double[] generateRandomMove(double myPosX, double myPosY) {
		double distance = Geometry.distance(myPosX, myPosY, x, y);
		if(distance < JUMPING_DISTANCE) {
			double angle = Geometry.angleBetweenTwoPoints(x, y, myPosX, myPosY) + random.nextGaussian()*ALPHA;
			x += JUMPING_DISTANCE*2*Math.cos(angle);
			y += JUMPING_DISTANCE*2*Math.sin(angle);
//			switch(random.nextInt(567843578) % 8) {
//            case 0:
//                x += JUMPING_DISTANCE;
//                break;
//            case 1:
//                x += JUMPING_DISTANCE;
//                y += JUMPING_DISTANCE;
//                break;
//            case 2:
//                y += JUMPING_DISTANCE;
//                break;
//            case 3:
//                x -= JUMPING_DISTANCE;
//                y += JUMPING_DISTANCE;
//                break;
//            case 4:
//                x -= JUMPING_DISTANCE;
//                break;
//            case 5:
//                x -= JUMPING_DISTANCE;
//                y -= JUMPING_DISTANCE;
//                break;
//            case 6:
//                y -= JUMPING_DISTANCE;
//                break;
//            case 7:
//                x += JUMPING_DISTANCE;
//                y -= JUMPING_DISTANCE;
//                break;
//            }
		}
		return null;
	}
}
